package com.wlr.study.leetcode;

public class LeetCode80 {
    public static int removeDuplicates(int[] nums) {
        int i = 0, j = 0, count = 0, temp = nums[0];
        while (j < nums.length) {
            if (nums[j] == temp) {
                if (++count >= 3) {
                    j++;
                    continue;
                }
            } else {
                count = 1;
                temp = nums[j];
            }
            nums[i++] = nums[j++];
        }
        return i;
    }

    public static void main(String[] args) {
        System.out.println(LeetCode80.removeDuplicates(new int[]{0, 0, 1, 1, 1, 1, 2, 3, 3}));
    }
}
